package net.maku.project.dao;

import net.maku.framework.mybatis.dao.BaseDao;
import net.maku.project.entity.ProcessStatesEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;


/**
* 流程状态表
*
* @author 艾力 1106997025@qq.com
* @since 1.0.0 2024-07-09
*/
@Mapper
public interface ProcessStatesDao extends BaseDao<ProcessStatesEntity> {

    /**
     * 检查阶段内所有环节是否已完成
     *
     * @param stageId 阶段ID
     * @return true 如果所有环节已完成，否则 false
     */
    boolean isAllStepsCompletedInStage(@Param("stageId") Long stageId,@Param("projectId")Long projectId);

    // SQL映射文件中的查询语句ID
    @Select("SELECT * FROM process_states WHERE timer_started = 1 AND completed = 0")
    @ResultMap("processStatesMap")
    List<ProcessStatesEntity> selectInProgressStates();

}